package com.company;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * Created by v on 17-3-9.
 */
public class ConnectMysql {
    private static String url="jdbc:mysql://localhost:3306/dictionary";
    /**
     * 不允许创建ConnectMysql方法
     */
    private ConnectMysql(){}

    public static Connection getConnection()throws SQLException{
        return getConnection("v","008748");
    }

    public static Connection getConnection(String name,String password) throws SQLException {
        try {
            Class.forName("com.mysql.jdbc.Driver");
        }catch (ClassNotFoundException ex){
            ex.printStackTrace();
        }

        return DriverManager.getConnection(url,name,password);
    }
}
